package com.xfgg.cloud.domain.model.entities;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @author xfgg
 */
@Data
public class JwtUser implements UserDetails {
    private String userName;
    private String passWord;
    private Collection<? extends GrantedAuthority> authorities;

    public JwtUser(){

    }
    public JwtUser(UserInfo userInfo){
        userName = userInfo.getUserName();
        passWord = userInfo.getPassWord();

    }

    @Override
    public String getPassword() {
        return passWord;
    }

    @Override
    public String getUsername() {
        return userName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }
}
